<?php
header('Content-Type:text/html;Charset=UTF-8');

session_start();

if(isset($_SESSION['user'])){

}else {
	die('<h3>登录信息不完整</h3><a href="/index.php">返回重新登录</a>');
};

@$pageNo = $_REQUEST['pageNo'];

if (empty($pageNo)||!is_numeric($pageNo)||$pageNo<1){
	$pageNo = 1;
}

$pageSizet = 7;

$offset = ($pageNo-1)*$pageSizet;

require 'lib/db.php';

@$itemCount = dbSelect('select count(1) as x from entry');

$pageCount = ceil($itemCount['x']/$pageSizet);

@$list = dbSelectAll("select e.id as eId,e.name as eName,price,imgUrl,purchase,mode,typeId from entry as e order by id asc limit $offset,$pageSizet");

// @$type = dbSelectAll('select t.name as tName from type as t join e on t.id=e.typeId');

// @$list = dbSelectAll("select e.id as eId,e.name as eName,price,imgUrl,purchase,mode,t.name as tName from entry as e order by id asc limit $offset,$pageSizet join type as t on e.typeId=t.id ");

?>
<!DOCTYPE html>
<html>
   <head>
      <title>SuperMarket</title>
	  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" charset="UTF-8" >
      <meta name="viewport" content="width=device-width, initial-scale=1.0">
      <link href="bootstrap/css/bootstrap.min.css" rel="stylesheet">
      <script src="bootstrap/js/jquery-1.11.1.min.js"></script>
      <script src="bootstrap/js/bootstrap.min.js"></script>
      <!--[if lt IE 9]>
         <script src="js/html5shiv.js"></script>
         <script src="js/respond.min.js"></script>
      <![endif]-->
   </head>
   <style>
    #a{color:#62b0ff;}
    .tr{font-weight:bold;background:#89dcd6;}
    .title{font-size:25px;color:red}
    .but{text-align: center;}
   </style>
   <body>
<div class="navbar navbar-default">
  <div class="container">
  	<a class="navbar-brand glyphicon glyphicon-shopping-cart" href="First.php" id="a">宜家超市</a>
  		<ul class="nav navbar-nav">
  			<li class="dropdown">
  				<a href="#" class="dropdown-toggle" data-toggle="dropdown" >档案管理 <span class="caret"></span></a>
  					<ul class="dropdown-menu">
  					<li><a href="manager.php">职工列表</a></li>
  					<li><a href="member.php">管理员</a></li>
  					</ul>
  			</li>
  		  </ul>
		<ul class="nav navbar-nav">
			<li class="dropdown">
			 <a href="#" class="dropdown-toggle" data-toggle="dropdown" >商品管理 <span class="caret"></span></a>
				<ul class="dropdown-menu">
					<li><a href="Addmerchandise.php">添加商品</a></li>
					<li><a href="merchandiseDish.php">商品列表</a></li>
				</ul>
			</li>
		  </ul>
		<ul class="nav navbar-nav">
			<li class="dropdown">
				<a href="#" class="dropdown-toggle" data-toggle="dropdown" >营业管理 <span class="caret"></span></a>
					<ul class="dropdown-menu">
						<li><a href="#">支出明细</a></li>
						<li><a href="income.php">收入明细</a></li>
					</ul>
				</li>
			</ul>
			<ul class="nav navbar-nav">
			<li class="dropdown">
			 <a href="#" class="dropdown-toggle" data-toggle="dropdown" >我的购物车 <span class="caret"></span></a>
				<ul class="dropdown-menu">
					<li><a href="Adddesk.php">我的商品</a></li>
					<li><a href="#">消费记录</a></li>
					<li><a href="#">我的收藏</a></li>
				</ul>
			</li>
		  </ul>
			<ul class="nav navbar-nav">
			<li class="dropdown">
				<a href="#" class="dropdown-toggle" data-toggle="dropdown" >权限管理 <span class="caret"></span></a>
					<ul class="dropdown-menu">
						<li><a href="#">我的权限</a></li>
						<li><a href="#">关于超市</a></li>
					</ul>
				</li>
			</ul>
	 	 <ul class="nav navbar-nav">
	  		<li class="dropdown">
	  			<a href="#" class="dropdown-toggle" data-toggle="dropdown" >登录管理 <span class="caret"></span></a>
	  				<ul class="dropdown-menu">
				  		<li><a href="#"  data-toggle="modal" data-target="#2">退出登录</a></li>
	  				</ul>
		</li>
	</ul>
 </div>
</div>
	<div id="2" class="modal">
					<div class="modal-dialog">				
					<div class="modal-content">
							<div class="modal-header">
								<span class="close" data-dismiss="modal">&times;</span>
								  <div class="modal-title">
									<h4>确定退出登录</h4>
								  </div>
									</div>
							<div class="modal-body">
								你确定要退出登录吗？
							</div>
							<div class="modal-footer">
							 <a type="submit" class="btn btn-default" href="logout.php">确定</a>
							 <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
							</div>
						</div>
					</div>
				</div>
<div class="container">
	<div class="panel panel-default">
 			<div class="panel-heading ">
 				<h4 class="panel-title title">商品信息列表</h4>
 			</div>
 			<div class="panel-body">
 				<table class="table table-bordered text-center">
 					<tr class="tr">
 						<td>商品编号</td>
 						<td>商品名称</td>
 						<td>图片</td>
 						<td>采购价格</td>
 						<td>销售价格</td>
 						<td>销售状态</td>
 						<td>基本状态</td>
 						<td>商品类型</td>
 						<td>处理方式</td>
 					</tr>
 					<?php 
 					foreach ($list as $eitm){
 					?>
 					<tr>
 						<td><?php echo $eitm['eId']; ?></td>
 						<td><?php echo $eitm['eName']; ?></td>
 						<td>
 						<img style="height:30px; "src="img/<?php echo $eitm['imgUrl']; ?>"/>
 						</td>
 						<td><?php echo $eitm['purchase']; ?></td>
 						<td><?php echo $eitm['price']; ?></td>
 						<td><?php echo $eitm['mode']; ?></td>
 						<td>正常</td>
 						<td><?php echo $eitm['typeId']; ?></td>
 						<td>
 							<a href="alterMoney.php?id=<?php echo $eitm['eId']; ?>">修改价格</a>
 						</td>
 					
 					</tr>
 					<?php }?>
 				</table>
 				
		 		<div class="col-xs-12 but">
		 			<a href="?pageNo=1">首页</a>
			 		<?php if($pageNo<=1){?>
						上一页
					<?php }else{?>
		 			<a href="?pageNo=<?php echo $pageNo-1; ?>">上一页</a>
		 			<?php }?>
				
					<?php if($pageNo>=$pageCount){?>
					下一页
					<?php }else{?>
		 			<a href="?pageNo=<?php echo $pageNo+1; ?>">下一页</a>
		 			<?php }?>
		 			<a href="?pageNo=<?php echo $pageCount; ?>">末页</a>
		 		</div>
 			</div>
 		</div>
 		</div>
 		
</body>
</html>


